//
//  FindViewController.m
//  项目
//
//  Created by 张诗雨 on 14/12/29.
//  Copyright (c) 2014年 张诗雨. All rights reserved.
//

#import "FindViewController.h"
#import "WebColor.h"
#import "FragmentViewController.h"
#import "GroupViewController.h"
#import "HotUserViewController.h"
@interface FindViewController ()

@end

@implementation FindViewController
- (void)dealloc
{
    [super dealloc];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [WebColor whiteSmoke];
    self.title = @"Found";
    [self createView];
    [self createSreachView];

}
- (void)buttonAction:(id)sender
{
    UIButton *button = (id)sender;
    if (button.tag == 10) {
        FragmentViewController *framentVC = [[FragmentViewController alloc] init];
        [self.navigationController pushViewController:framentVC animated:YES];
        [framentVC release];
    } else if (button.tag == 11){
        GroupViewController *groupVC = [[GroupViewController alloc] init];
        [self.navigationController pushViewController:groupVC animated:YES];
        [groupVC release];
    } else if (button.tag == 12) {
        HotUserViewController *hotUserVC = [[HotUserViewController alloc] init];
        [self.navigationController pushViewController:hotUserVC animated:YES];
        [hotUserVC release];
    }
    
}
- (void)createSreachView
{

}
- (void)createView
{
    NSArray *picArr = [[NSArray alloc] initWithObjects: @"find_suipian.png", @"find_group.png", @"find_user.png", @"find_more.png",nil];
    NSArray *titleArr = [[NSArray alloc] initWithObjects: @"碎片", @"互动", @"热门用户", @"更多设置", nil];
    NSInteger width = (self.view.frame.size.width - 150 )/ 3;
    for (int i = 0; i < 4; i++) {
        /// 设置背景颜色的view
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(20 + i % 3 * (width + 50), 120 + i / 3 * (width + 80), width, width)];
        view.tag = i + 100;
        [self.view addSubview:view];
        
        /// 设置显示图片
        UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake( 15, 15, width - 30, width - 30)];
        imgView.image = [UIImage imageNamed:[picArr objectAtIndex:i]];
        [view addSubview:imgView];
        
        /// 触发点击方法
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.tag = i + 10;
        [button addTarget:self action:@selector(buttonAction:   ) forControlEvents:UIControlEventTouchUpInside];
        button.frame = CGRectMake(0, 0, width, width);
        [view addSubview:button];
        [view release];
        [imgView release];
        
        ///  标题
        UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(20 + i % 3 * (width + 50), 130 + i / 3 * (width + 80) + width, width, 30)];
        lable.textAlignment = NSTextAlignmentCenter;
        lable.font = [UIFont boldSystemFontOfSize:14.0f];
        lable.textColor = [WebColor slateGray];
        lable.text = [titleArr objectAtIndex:i];
        [self.view addSubview:lable];
        [lable release];
    }
    UIView *view1 = (UIView *)[self.view viewWithTag:100];
    view1.backgroundColor = [WebColor wheat];

    UIView *view2 = (UIView *)[self.view viewWithTag:101];
    view2.backgroundColor = [WebColor lightCoral];
    
    UIView *view3 = (UIView *)[self.view viewWithTag:102];
    view3.backgroundColor = [WebColor lightBlue];
    
    UIView *view4 = (UIView *)[self.view viewWithTag:103];
    view4.backgroundColor = [WebColor rosyBrown];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}



@end
